/* xerror.c -- Camada de abstração para chamada de erros
 * 
 * Copyright (C) 2007 Diogo F. S. Ramos <diogofsr@users.sourceforge.net>
 *
 * This file is part of Engcur.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
*/

/** @file
 * 
 * Camada de abstração para chamada de erros
 */

#include <stdio.h>
#include <stdlib.h>

#include "error.h"

static void error_message( int exit_status,
			   const char *mode,
			   const char *message );

void
error_message( int exit_status, const char *mode, const char *message )
{
    fprintf( stderr, "roboboca:%s:%s\n", mode, message );

    if( exit_status >= 0 )
    {
	exit(exit_status);
    }

    return;
}

void
xerror_warning( const char *message )
{
    error_message( -1, "warning", message );

    return;
}

void
xerror_error( const char *message )
{
    error_message( -1, "error", message );

    return;
}

void
xerror_fatal( const char *message )
{
    error_message( 0, "FATAL", message );

    return;
}
